package com.sx.email.controller;

import com.sx.email.Vo.MailVo;
import com.sx.email.service.MailSender;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author shengx
 * @date 2020/5/10 21:10
 */
@RestController
@RequestMapping("/email")
public class EmailController {

    @Autowired
    private MailSender mailSender;
    @GetMapping("/{email}/{code}")
    public Boolean email(@PathVariable String email, @PathVariable String code){
        MailVo mailVo = new MailVo();
        mailVo.setFrom("243725821@qq.com");
        mailVo.setTo(email);
        mailVo.setId("1");
        mailVo.setSubject("验证码");
        mailVo.setText(code);
        MailVo mailVo1 = mailSender.sendMail(mailVo);
        System.out.println(mailVo1);
        System.out.println("email:" + email + " code:" + code);
        if(mailVo1.getStatus().equals("OK")){
            return true;
        }
        return false;
    }
}
